<?php
if (!defined('WEB_ROOT')) {
	exit;
}

$rowsPerPage = 5;

$sql = "SELECT nnc.id, mannc, tennnc, tendv, date_format(nnc.ngaythanhlap,'%d-%m-%Y') as ngaythanhlap, nnc.ngayketthuc, dv_id
        FROM nhomnc nnc left join donvi dv on nnc.dv_id = dv.id
		WHERE nnc.hieu_luc > 0
		ORDER BY nnc.id desc";
//echo $sql;
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
		
//$groupList = buildGroupOptions($mannc);
?> 
<!-- Begin one column window -->
<div class="onecolumn">
				<div class="header">
					<span>Tác giả</span>
					<div class="switch" style="width:140px">
						<table width="140px" cellpadding="0" cellspacing="0">
						<tbody>
							<tr>
								<td>
									<input name="btnAddGroup" class="middle_switch" type="button" id="btnAddGroup" value="Thêm nhóm nghiên cứu"  style="width:140px" onClick="addGroup()">
								</td>
							</tr>
						</tbody>
						</table>
					</div>
				</div>
				<br class="clear"/>
				<div class="content">
					<form action="processGroup.php?action=addGroup" id="form_data" name="form_data" action="" method="post">
					 <!--<table width="100%" border="0" cellspacing="0" cellpadding="2" class="text">
					  <tr>
					   <td align="right">View Groups in : 
						<select name="cboGroup" class="box" id="cboGroup" onChange="viewGroup();">
						 <option selected>All Group</option>
						<?php echo $groupList; ?>
					   </select>
					 </td>
					 </tr>
					</table>-->
					 <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1"  class="data" >
						  <tr align="center" id="listTableHeader"> 
							   <th width="150" align="center">Mã nhóm nghiên cứu</th>
							   <th>Tên nhóm nghiên cứu</td>
							   <th width="240">Đơn vị</th>
							   <th width="85">Ngày thành lập</th>
							   <th width="85">Ngày kết thúc</th>
							   <th width="30">Sửa</th>
							   <th width="30">Xóa</th>
						  </tr>
					  <?php
						if (dbNumRows($result) > 0) {
						$i = 0;
						
						while($row = dbFetchAssoc($result)) {
							extract($row);
							if ($i%2) {
								$class = 'row1';
							} else {
								$class = 'row2';
							}
							$i += 1;
					?>
					  <tr class="<?php echo $class; ?>"> 
						   <!--<td width="90" align="center"><a href="index.php?view=detail&id=<?php echo $id; ?>"><?php echo $id; ?></a></td>-->
						   <td width ="150" align="center"><?php echo $mannc; ?></td>
						   <td><?php echo $tennnc; ?></td>
						   <td width="240" align="center"><?php echo $tendv; ?></td>
						   <td width="85" align="center"><?php echo $ngaythanhlap; ?></td>
						   <td width="85" align="center"><?php echo $ngayketthuc; ?></td>
						   <td width="30" align="center"><a href="javascript:modifyGroup(<?php echo $id; ?>, <?php echo (int)$dv_id; ?>);">Sửa</a></td>
						   <td width="30" align="center"><a href="javascript:deleteGroup(<?php echo $id; ?>);">Xóa</a></td>
					  </tr>
					  <?php
						} // end while
						if(isset($pagingLink)){
					?>
					  <tr> 
					   <td colspan="7" align="center">
					   <?php 
					echo $pagingLink;
					   ?></td>
					  </tr>
					<?php	
					}
					} else {
					?>
					  <tr> 
					   <td colspan="7" align="center">Không có nhóm nghiên cứu nào</td>
					  </tr>
					  <?php
					}
					?>
					 </table>
					 <p>&nbsp;</p>
					</form>
								
		</div>
</div>
	<!-- End one column window -->